package com.wuhuahe.learning.lagou.service.code.controller;


import com.wuhuahe.learning.lagou.service.dubbo.api.CodeService;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/code")
public class CodeController {

    @Reference
    private CodeService codeService;

    @GetMapping("/create/{email}")
    public boolean create(@PathVariable("email") String email) {
        System.out.println(email);
        codeService.createCode(email);
        return true;
    }

    @GetMapping("/validate/{email}/{code}")
    public int validate(@PathVariable("email") String email, @PathVariable("code") String code) {
        return codeService.validate(email, code);
    }
}
